<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BApplication
 *
 * @author jianfeng
 */
class BApplication {

    //put your code here

    private $currentUser = null;
    private $db = null;
    private $appUi = null;
    private $appPool = null;
    private $activeService = null;
    private $activeApp = null;
    private $activeOpp = null;

    /**
     *
     * @return BUser
     */
    public function getCurrentUser() {
        if ($this->currentUser == null)
            $this->currentUser = new BUser();

        return $this->currentUser;
    }

    /**
     *
     * @return BAppDb
     */
    public function getAppDb() {
        if ($this->db == null)
            $this->db = new BAppDb ();

        return $this->db;
    }

    /**
     *
     * @return BUIApp
     */
    public function getAppUI() {
        if ($this->appUi == null)
            $this->appUi = new BUIApp ();

        return $this->appUi;
    }

    /**
     *
     * @return BAppPool 
     */
    public function getAppPool() {
        if ($this->appPool == NULL)
            $this->appPool = new BAppPool ();

        return $this->appPool;
    }

   /**
    *
    * @return BService
    */
    public function getActiveService() {
        return $this->activeService;
    }

    /**
     *
     * @return BServiceApp
     */
    public function getActiveServiceApp() {
        if ($this->activeApp == NULL)
            $this->activeApp = isset($this->activeService) ? new BServiceEngine($this->activeService) : new BServiceEngine;
        return $this->activeApp;
    }

    /**
     *
     * @return BOperation
     */
    public function getActiveOperation() {
        return $this->activeOpp;
    }

    public function setActiveService($service) {
        $this->activeService = $service;
    }

    public function setActiveServiceApp($app) {
        $this->activeApp = $app;
    }

    public function setActiveOperation($operation) {
        $this->activeOpp = $operation;
    }

}

?>
